﻿Module Module1
  Sub Main()
    Dim dataStringa As String
    Dim data As Date

    dataStringa = "20101001"
    data = YYYYMMDD_ToDateTime(dataStringa)
    Console.WriteLine(Day(data).ToString & "/" &
                      Month(data).ToString & "/" &
                      Year(data).ToString)

    dataStringa = "01/10/2010"
    data = GGMMAAAA_ToDateTime(dataStringa)
    Console.WriteLine(Day(data).ToString & "," &
                      Month(data).ToString & "," &
                      Year(data).ToString)
    Console.ReadLine()
  End Sub

  Private Function YYYYMMDD_ToDateTime(
        ByVal YYYYMMDD As String) As DateTime
    Dim myCultureInfo As New  _
      System.Globalization.CultureInfo(
        "it-IT", True)
    Dim formato As String = "yyyyMMdd"
    Return _
      System.DateTime.ParseExact(
        YYYYMMDD, formato, myCultureInfo)
  End Function

  Private Function GGMMAAAA_ToDateTime(
       ByVal GGMMAAAA As String) As DateTime
    Dim myCultureInfo As New  _
      System.Globalization.CultureInfo(
        "it-IT", True)
    Dim formato As String = "dd/MM/yyyy"
    Return _
      System.DateTime.ParseExact(
        GGMMAAAA, formato, myCultureInfo)
  End Function

End Module
